package co.com.javeriana.aes.patrones.endpoint;

import java.io.IOException;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public abstract class EndPoint {

	protected Channel channel;
	protected Connection connection;
	protected String endPointName;

	public EndPoint(String endpointName) throws IOException {
		this.endPointName = endpointName;

		ConnectionFactory factory = new ConnectionFactory();
		factory.setHost("25.124.75.91");
		factory.setUsername("admin");
		factory.setPassword("123");
		connection = factory.newConnection();
		channel = connection.createChannel();
		channel.queueDeclare(endpointName, true, false, false, null);
	}
	
	public void close() throws IOException {
		this.channel.close();
		this.connection.close();
	}
}